#include "stdafx.h"
#include <boost/test/auto_unit_test.hpp>
#include "bmock.hpp"
#include "test_generate_mock_class_newmocks.hpp"


struct arg_test3{};

BMOCK_TEST(arg_test3,test_create_mock_for_all_methods_of_class)
{
	int expected_result=6;
	int arg1=23;
	int result=20;
	test_generate_mock_class3 X(8);
	
	BMOCK_CREATE_MOCK(test_generate_mock_class3::*);
	BMOCK_EXPECT(X.l());
	BMOCK_EXPECT_RETURN(expected_result,X.h(arg1));
	BMOCK_REPLAY;
	BOOST_CHECK_NO_THROW(X.l();)
		BOOST_CHECK_NO_THROW(result=X.h(arg1);)
		BMOCK_VERIFY;
	BOOST_CHECK_EQUAL(expected_result,result);
}

BMOCK_TEST(arg_test3,test_create_mock_for_all_methods_of_class_check_constructor)
{
	test_generate_mock_class3* ptr = 0;
	test_generate_mock_class3* ptr1 = 0;
	double a=12;
	double b=24;
	BMOCK_CREATE_MOCK(test_generate_mock_class3::*);
	BMOCK_EXPECT(ptr=new test_generate_mock_class3(a));
	BMOCK_REPLAY;
	BOOST_CHECK_NO_THROW(ptr1=new test_generate_mock_class3(b))
		BMOCK_VERIFY;
	BOOST_CHECK_EQUAL(a,b);
	BOOST_CHECK_NO_THROW(delete ptr1);
	BOOST_CHECK_NO_THROW(delete ptr);
}

BMOCK_TEST(arg_test3,test_create_mock_for_all_methods_of_class_test_destructor)
{
	test_generate_mock_class23* ptr1;
	BMOCK_CREATE_MOCK(test_generate_mock_class23::*)
		test_generate_mock_class23* ptr=new test_generate_mock_class23;
	ptr1=new test_generate_mock_class23;
	BMOCK_EXPECT(delete ptr);
	BMOCK_REPLAY;
	BOOST_CHECK_NO_THROW(delete ptr1;);
	BMOCK_VERIFY;
}

BMOCK_TEST(arg_test3,test_create_mock_for_all_methods_starting_with)
{
	int expected_result=6;
	int expected_arg1=23;
	int actual_arg1=53;
	int result=20;
	test_generate_mock_class3 X(8);
	BMOCK_CREATE_MOCK(test_generate_mock_class3::method*);
	BMOCK_EXPECT(X.method_g(expected_arg1));
	BMOCK_EXPECT_RETURN(expected_result,X.method_f());
	BMOCK_REPLAY;
	BOOST_CHECK_NO_THROW(X.method_g(actual_arg1);)
		BOOST_CHECK_NO_THROW(result=X.method_f();)
		BMOCK_VERIFY;
	BOOST_CHECK_EQUAL(expected_result,result);
	BOOST_CHECK_EQUAL(expected_arg1,actual_arg1);
}
BMOCK_TEST(arg_test3,test_create_mock_for_a_specific_method)
{
	int expected_arg1=23;
	int actual_arg1=53;
	test_generate_mock_class3 X(8);
	BMOCK_CREATE_MOCK(test_generate_mock_class3::method_g);
	BMOCK_EXPECT(X.method_g(expected_arg1));
	BMOCK_REPLAY;
	BOOST_CHECK_NO_THROW(X.method_g(actual_arg1);)
		BMOCK_VERIFY;
	BOOST_CHECK_EQUAL(expected_arg1,actual_arg1);
}

BMOCK_TEST(arg_test3,testVoidMethodNotMock) {
	test_generate_mock_class3 x(8);
	BOOST_CHECK_NO_THROW(x.l();)
		BOOST_CHECK_EQUAL(x.my_val,43);
}

BMOCK_TEST(arg_test3,testNotVoidMethodNotMock) {
	test_generate_mock_class3 x(8);
	int result;
	int expected2=10;
	BOOST_CHECK_NO_THROW(result=x.h(expected2);)
		BOOST_CHECK_EQUAL(result,expected2);
}



BMOCK_TEST(arg_test3,testNotVoidConstMethodNotMock) {
	test_generate_mock_class3 x(8);
	int result;
	BOOST_CHECK_NO_THROW(result=x.method_f();)
		BOOST_CHECK_EQUAL(result,8);
}

BMOCK_TEST(arg_test3,testVoidConstMethodBmock_Generate_code) {
	test_generate_mock_class3 x(8);
	int result=1;
	BOOST_CHECK_NO_THROW(x.method_g(result);)
		BOOST_CHECK_EQUAL(result,8);
}


BMOCK_TEST(arg_test3,test_constructor_Bmock_not_mock) {
	test_generate_mock_class3* ptr1;
	double a=24;
	double b;
	ptr1=new test_generate_mock_class3(b);
	BOOST_CHECK_EQUAL(b,a);
	BOOST_CHECK_NO_THROW(delete ptr1);
}


BMOCK_TEST(arg_test3,test_destructor_Bmock_Generate_code) {
	test_generate_mock_class23* ptr1;
	ptr1=new test_generate_mock_class23;
	BOOST_CHECK_NO_THROW(delete ptr1;)
}

